<?php
namespace app\admin\validate;

use think\Validate;

class Member extends Validate
{
    protected $rule = [
	    ['account','require|alphaDash|unique:member','请输入账户|只能是字母、数字和下划线_及破折号-|账户已存在'],
	    ['password','require|password:1','请输入密码'],
	    ['first_name','require','请输入名'],
	    ['surnames','require','请输入姓'],
//	    ['organization','require','请输入公司'],
//	    ['date_of_birth','require|date','请输入日期|请输入正确的日期'],
//	    ['phone','require|is_tel:1','请输入电话'],
	    ['email','require|email','请输入电邮|电邮格式错误'],
	    ['certificate_code','require','请输入证书编号'],
        
            ['level_price','require|number','请输入会员价格|只能是数字'],
    ];

     protected $scene = [
        'add'  =>  ['names','password','first_name','surnames','email','certificate_code'],
        'edit'  =>  ['names','first_name','surnames','email','certificate_code'],
        'level'  =>  ['level_price'],
    ]; 
     
     
     
     protected function password($value){
        if($value){
            $exp = "/^(?![^a-zA-Z]+$)(?!\D+$).{9,25}$/";  
            if(preg_match($exp,$value)){  
                return true;  
            }else{  
                return '密码格式不正确';  
            }  
        }
    }
     
//    protected function is_tel($value){
//        if($value){
//            $exp = "/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/";  
//            $exp2 = "/^\d{3,4}-?\d{7,9}$/";  
//            if(preg_match($exp,$value) || preg_match($exp2,$value)){  
//                return true;  
//            }else{  
//                return '电话格式不正确';  
//            }  
//        }
//    }
     
}